﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BackTask.Model
{
    public abstract class BackTaskConfiguration
    {
        protected abstract List<TaskJob> Jobs { get; set; }
        public abstract IEnumerable<TaskJob> BindJobs();

        public abstract void UseConfiguration(object configuration);

        public abstract void BuildConfiguration();

        public abstract StorageTypes StorageType { get; }

        public abstract void DeleteConfiguration(string name, string groupName);

        public abstract void AddConfiguration(TaskJob job);
        public abstract void UpdateConfiguration(TaskJob job);

        public virtual bool HasSameJob(string name, string groupName)
        {
            return this.Jobs.FirstOrDefault(r => r.Name == name && r.GroupName == groupName) != null;
        }

        public virtual IEnumerable<TaskJob> GetJobs()
        {
            return this.Jobs;
        }

        public virtual TaskJob GetJob(string name, string groupName)
        {
            return this.Jobs.FirstOrDefault(r => r.Name == name && r.GroupName == groupName);
        }
    }
}
